package com.qunduikj.sjb.sdk.handler;

import android.content.Intent;
import android.net.Uri;
import com.litesuits.sdk.LiteApp;
import com.litesuits.sdk.handler.DefaultUncaughtHandler;

/**
 * Try to catch the uncaught exception. when a thread exits due to an uncaught
 * exception, we log a message and exit.
 *
 * @author MaTianyu on 2015-05-05
 */
public class UncaughtHandler extends DefaultUncaughtHandler {
    private static final String TAG = UncaughtHandler.class.getSimpleName();

    @Override
    protected void handleException(Thread t, Throwable e) {
        Intent welcome = new Intent(Intent.ACTION_VIEW);
        welcome.setData(Uri.parse("sjb://action/welcome"));
        welcome.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                         | Intent.FLAG_ACTIVITY_NEW_TASK
                         | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        LiteApp.getInstance().startActivity(welcome);
    }
}